import { PromiseResponse } from '@/types/type'
import { request } from '@/utils/request'
import { UpdatePasswordForm, UpdateUserInfoForm } from './type'

/* eslint-disable no-unused-vars */
enum API {
    RESET_PASSWORD_URL = '/User/PasswordReset',
    UPDATE_PASSWORD_URL = '/User/UpdatePassword',
    UPDATE_USER_INFO_URL = '/User/UpdateUserInfo',
    UPDATE_PHONE_NUMBER_URL = '/User/UpdatePhoneNumber',
    UPDATE_EMAIL_URL = '/User/UpdateEmail',
    UPDATE_AVATAR_URL = '/User/UpdateAvatar',
}
/**
 * 重置密码
 * @param id 需要重置密码的数据id
 * @param ids 需要重置密码的数据id集合
 * @returns
 */
export const resetPassword = (id: number, ids: number[]): PromiseResponse<boolean> => request(API.RESET_PASSWORD_URL, 'POST', { id, ids }, {})
/**
 * 更新用户基本信息
 * @param form 修改用户基本信息表单
 * @returns
 */
export const updateUserInfo = (form: UpdateUserInfoForm): PromiseResponse<boolean> => request(API.UPDATE_USER_INFO_URL, 'POST', form, {})
/**
 * 修改密码
 * @param form 修改密码表单
 * @returns
 */
export const updatePassword = (form: UpdatePasswordForm): PromiseResponse<boolean> => request(API.UPDATE_PASSWORD_URL, 'POST', form, {})
/**
 * 修改手机号码
 * @param id 用户Id
 * @param phoneNumber 手机号码
 * @returns
 */
export const updatePhoneNumber = (id: number, phoneNumber: string): PromiseResponse<boolean> =>
    request(API.UPDATE_PHONE_NUMBER_URL, 'POST', { id, phoneNumber }, {})
/**
 * 修改邮箱
 * @param id 用户Id
 * @param email 邮箱
 * @returns
 */
export const updateEmail = (id: number, email: string): PromiseResponse<boolean> => request(API.UPDATE_EMAIL_URL, 'POST', { id, email }, {})
/**
 * 修改头像
 * @param id 用户Id
 * @param avatar 头像文件url
 * @returns
 */
export const updateAvatar = (id: number, avatar: string): PromiseResponse<boolean> => request(API.UPDATE_AVATAR_URL, 'POST', { id, avatar }, {})
